package com.xky.service.impl;

import com.xky.mapper.ScoreMapper;
import com.xky.pojo.Score;
import com.xky.pojo.Student;
import com.xky.service.ScoreService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ScoreImpl implements ScoreService {
    private static final Logger logger = LoggerFactory.getLogger(ScoreImpl.class);
    
    @Autowired
    private ScoreMapper scoreMapper;
    /**
     * 添加学生的成绩
     * @param score
     */
    @Override
    public void addScore(Score score) {
        try {
            logger.info("准备添加成绩: {}", score);
            scoreMapper.addScore(score);
            logger.info("成绩添加成功");
        } catch (Exception e) {
            logger.error("添加成绩时出错: {}", e.getMessage(), e);
            throw e;
        }
    }

    /**
     * 删除学生的成绩
     * @param stuid
     */
    @Override
    public void deleteScore(Integer stuid) {
        scoreMapper.deleteScore(stuid);
    }

    /**
     * 修改学生的成绩
     * @param score
     */
    @Override
    public void updateScore(Score score) {
        scoreMapper.updateScore(score);
    }

    /**
     * 根据id查找学生的成绩
     * @param stuid
     * @return
     */
    @Override
    public Score selectById(Integer stuid) {
        return scoreMapper.selectById(stuid);
    }

    @Override
    public List<Score> selectAllScore() {
        return scoreMapper.selectAllScore();
    }
}
